;;find important words

(defun top-n-words (n linkedwordinventory) "gives all the words with the n highest frequencies. takes from link-words function"
  (let (
	(templist (car linkedwordinventory))
	(reflist (car linkedwordinventory))
	(reffreq (nth 1 linkedwordinventory))
	(top-n-freq (subseq (remove-duplicates (sort (copy-seq (nth 1 linkedwordinventory)) #'>)) 0 n))
	(output '())
       )
       
       (while top-n-freq do
	      (while templist do
		     (if (= (car top-n-freq) (nth (wordindex (car templist) reflist) reffreq))
			 (setq output (left-rotate (cons (car templist) output)))
		     )
		     (setq templist (cdr templist))
	      )

	      (setq templist reflist) ;;reset

	      (setq top-n-freq (cdr top-n-freq)) ;;look for next highest frequency
       )
       
       output
  )

)

(defun top-n-contexts (topwords parsedsentence) "returns the most relevant phrases of recurrent words with a list of topwords"
   (let (
        (words (flatten topwords))
	(templist parsedsentence)
	(outputlist '())
	)
     
   (while templist do

	(let ((tempwords words))
	(while tempwords do
	    (setq outputlist (left-rotate (cons (find-item (car tempwords) (car templist)) outputlist)))
	    (setq tempwords (cdr tempwords))
	)
	)

	(setq templist (cdr templist))
   )
   (remove nil outputlist)
   )
)


(defun subject-line-relevance (subjectline text) "finds words in the text that are relevant based on the subject line"
  
)